<button mat-raised-button (click)="onAddTriggered()">
  <mat-icon>add</mat-icon> 添加
</button>
<button mat-raised-button (click)="onDeleteTriggered()">
  <mat-icon>delete</mat-icon> 删除
</button>

<div class="mat-elevation-z8">
  <table mat-table [dataSource]="dataSource">
    <ng-container matColumnDef="select">
      <th mat-header-cell *matHeaderCellDef>
        <mat-checkbox
          (change)="$event ? masterToggle() : null"
          [checked]="selection.hasValue() && isAllSelected()"
          [indeterminate]="selection.hasValue() && !isAllSelected()"
        >
        </mat-checkbox>
      </th>
      <td mat-cell *matCellDef="let row">
        <mat-checkbox
          (click)="$event.stopPropagation()"
          (change)="$event ? selection.toggle(row) : null"
          [checked]="selection.isSelected(row)"
        >
        </mat-checkbox>
      </td>
    </ng-container>

    <ng-container matColumnDef="key">
      <th mat-header-cell *matHeaderCellDef>ID</th>
      <td mat-cell *matCellDef="let element">{{ element.key }}</td>
    </ng-container>

    <ng-container matColumnDef="username">
      <th mat-header-cell *matHeaderCellDef>用户名</th>
      <td mat-cell *matCellDef="let element">{{ element.username }}</td>
    </ng-container>

    <ng-container matColumnDef="nickname">
      <th mat-header-cell *matHeaderCellDef>昵称</th>
      <td mat-cell *matCellDef="let element">{{ element.nickname }}</td>
    </ng-container>

    <ng-container matColumnDef="role">
      <th mat-header-cell *matHeaderCellDef>角色</th>
      <td mat-cell *matCellDef="let element">{{ element.role }}</td>
    </ng-container>

    <ng-container matColumnDef="email">
      <th mat-header-cell *matHeaderCellDef>邮箱</th>
      <td mat-cell *matCellDef="let element">{{ element.email }}</td>
    </ng-container>

    <ng-container matColumnDef="phone">
      <th mat-header-cell *matHeaderCellDef>手机号</th>
      <td mat-cell *matCellDef="let element">{{ element.phone }}</td>
    </ng-container>

    <ng-container matColumnDef="createTime">
      <th mat-header-cell *matHeaderCellDef>创建时间</th>
      <td mat-cell *matCellDef="let element">{{ element.createTime }}</td>
    </ng-container>

    <ng-container matColumnDef="status">
      <th mat-header-cell *matHeaderCellDef>状态</th>
      <td mat-cell *matCellDef="let element">{{ element.status }}</td>
    </ng-container>

    <ng-container matColumnDef="star" stickyEnd>
      <th mat-header-cell *matHeaderCellDef>操作</th>
      <td
        mat-cell
        *matCellDef="let element"
        (click)="onEditorTriggered(element)"
      >
        编辑
      </td>
    </ng-container>

    <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
    <tr
      mat-row
      *matRowDef="let row; columns: displayedColumns"
      (click)="selection.toggle(row)"
    ></tr>
  </table>
</div>
